/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ejb.products;

import java.io.Serializable;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJBException;
import javax.ejb.Singleton;
import jpa.controller.ProductoinventarioJpaController;
import jpa.controller.exceptions.IllegalOrphanException;
import jpa.controller.exceptions.NonexistentEntityException;
import jpa.entities.Productoinventario;

/**
 *
 * @author Diego Curbelo
 */
@Singleton
public class ProductInvEJB implements Serializable{
    
    public ProductInvEJB() {
    }

    public List<Productoinventario> listarProductsInven()throws EJBException{
		List <Productoinventario> listProducts;
		listProducts = new ProductoinventarioJpaController().findProductoinventarioEntities();
		return listProducts;
    }

    public void updateProdInv(Productoinventario prod)throws EJBException{
        try {
            new ProductoinventarioJpaController().edit(prod);
        } catch (IllegalOrphanException ex) {
            Logger.getLogger(ProductInvEJB.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NonexistentEntityException ex) {
            Logger.getLogger(ProductInvEJB.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(ProductInvEJB.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void registrarProducto(Productoinventario prod)throws EJBException{
        try {
            new ProductoinventarioJpaController().create(prod);
        } catch (Exception ex) {
            Logger.getLogger(ProductInvEJB.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
 
}
